#ifndef SCRIPT_HELPER_H
#define SCRIPT_HELPER_H
#include <qstringlist.h>
#include "ScriptExecutor.h"

class ScriptHelper
{
public:
	ScriptCommandUnit createScriptCommand()
	{
		ScriptCommandUnit unit;
		unit.package = getPackage();
		unit.module = getModule();
		return unit;
	}

	virtual QString getPackage()const { return "SDKCore"; }
	virtual QString getModule()const { return "ScriptHelper"; }
};

#define STR(str) #str 

#define BUILD_AND_BIND_SCRIPT_COMMON_UNIT(fn,input,desc)\
{\
    ScriptCommandUnit unit = createScriptCommand();\
    unit.function = STR(fn);\
    unit.example = input;\
    unit.help = desc;\
    unit.call = [&](const QStringList& argument,QString* error) -> bool\
    {\
	    return fn(argument,error);\
    };\
    SDKCore::instance()->getScriptExecutor()->registerCommand(unit);\
}

#endif
